package designMode;

import java.awt.print.Book;

/**
 * @description:  依赖倒置原则  就是要依赖于抽象，不要依赖于具体
 * @author: cyy
 **/
public class dependency_Inversion {
    public static void main(String[] args){
        Mother mother = new Mother();
        mother.narrate(new BookNew());
        mother.narrate(new Newspaper());
    }
}

interface IReader{
    public String getContent();
}

class Newspaper implements IReader {
    @Override
    public String getContent(){
        return "大a超3000股下跌";
    }
}
class BookNew implements IReader{
    @Override
    public String getContent(){
        return "很久很久有个人爱我很久";
    }
}

class Mother{
    public void narrate(IReader reader){
        System.out.println("依赖倒置操作");
        System.out.println(reader.getContent());
    }
}
